/* START 1_tripCountsByDayAroundOpening.do */

/* this script compares trip counts by day for the 2015-2016 data by
origin/destination for the descriptive section. The goal is to compare the raw
number of trips around the event break. */

/* prerequisite packages: fillmissing, labutil2, gtools, parallel, sepscatter */
version 16.1
set more off
cap clear all

/* PATHS */
do "code/config.do"

/* Initialize 12 threads */
// parallel initialize 12

/* load accessory functions */
qui do "code/99_accessoryFunctions.do"
use "make_data/2015.dta", clear

/* fix labeling from earlier */
cap label copy oa1 oa
cap label drop oa1
cap label values oa da oa

/*********************************/
/** COLLAPSE THE 2015-2016 DATA **/
/*********************************/

/* compute trip dates */
gen tripDate = dofc(START)
format tripDate %td
drop if tripDate == .
drop if tripDate == td(02mar2016)
gen byte after = (tripDate >= td(27dec2015))

/* finer time subdivisions */
gen byte hr = hh(START)

/** Trip count by day, by CCK/not CCK **/
gen byte oCCK = (oa == "JELEBU":oa) | (oa == "HILLVIEW":oa) | (oa == "GOMBAK":oa)
gen byte dCCK = (da == "JELEBU":oa) | (da == "HILLVIEW":oa) | (da == "GOMBAK":oa)
/* gen byte wCCK = (oCCK == 1) & (dCCK == 1) */
gegen byte gCCK = group(oCCK dCCK)
gen byte CCK = (oCCK == 1) | (dCCK == 1)
gen byte obw = (oa == "ANAK BUKIT":oa)
gen byte dbw = (da == "ANAK BUKIT":oa)
gen byte bw = (obw == 1) | (dbw == 1)
gegen byte gbw = group(obw dbw)

gen byte odt = (op == "DOWNTOWN CORE":op)
gen byte ddt = (dp == "DOWNTOWN CORE":op)
gen byte dt = (odt == 1) | (ddt == 1)
gegen byte gdt = group(odt ddt)

gen byte geylang = (op == "GEYLANG":op) | (dp == "GEYLANG":op)
gen byte nearDTL = (oa == "GOMBAK":oa | da == "GOMBAK":oa) |  ///
  (oa == "JELEBU":oa | da == "JELEBU":oa) |  ///
  (oa == "HILLVIEW":oa | da == "HILLVIEW":oa) |  ///
  (oa == "ANAK BUKIT":oa | da == "ANAK BUKIT":oa) |  ///
  (oa == "HOLLAND ROAD":oa | da == "HOLLAND ROAD":oa) |  ///
  (oa == "SWISS CLUB":oa | da == "SWISS CLUB":oa) |  ///
  (oa == "CORONATION ROAD":oa | da == "CORONATION ROAD":oa) |  ///
  (oa == "TYERSALL":oa | da == "TYERSALL":oa) |  ///
  (oa == "NASSIM":oa | da == "NASSIM":oa) |  ///
  (oa == "NEWTON CIRCUS":oa | da == "NEWTON CIRCUS":oa) |  ///
  (oa == "FARRER PARK":oa | da == "FARRER PARK":oa) |  ///
  (oa == "BENCOOLEN":oa | da == "BENCOOLEN":oa) |  ///
  (oa == "BUGIS":oa | da == "BUGIS":oa)

/* TRIP COUNTS BY HOUR */
do "./descriptive/1a_rawTripCounts.do"
// do "${root}/code/descriptive/1b_tripCountsByHour.do"

/* COMPUTE MODAL TRIP BY PLANNING AREA BEFORE AND AFTER */
// do "${root}/code/descriptive/1c_tripTimesAroundOpening.do" 



